# load packages
library(groundhog)


pkgs <- c("foreign",
          "car",
          "tidyverse",
          "readxl",
          "gender",
          "sylcount",
          "wru",
          "babynames",
          "janitor",
          "ggpubr",
          "stargazer",
          "broom",
          "sandwich",
          "corrr",
          "kableExtra",
          "lmtest")

groundhog.library(pkgs, "2023-08-01")
groundhog.library('github::y2analytics/y2clerk','2023-12-16')
# groundhog.library("github::lmullen/genderdata", "2023-08-01")  # takes a long time to install
library(genderdata)
rm(pkgs)

# run scripts (in order)
source("code/1_merge-ced-data.R")
source("code/2a_clean-ced-data.R")
source("code/2b_clean-dime-data.R")
source("code/3_read-data-define-functions.R")
source("code/3b_code-regression-variables.R")
source("code/4_main-analysis.R")
source("code/5a_fullnames-analysis.R")
source("code/5b_individual-estimates-foreach-iv.R")
source("code/5c_competitive-elections.R")
source("code/5d_different-birth-years.R")
source("code/5e_drop-partial-names.R")
source("code/5f_bivariate-regressions.R")
source("code/5g_het-analysis-electoral-race.R")
source("code/5h_include-all-parties.R")
source("code/5i_het-analysis-gender.R")
source("code/6_summary-stats.R")
